home *** CD-ROM | disk | FTP | other *** search
/ Speccy ClassiX 1998 / Speccy ClassiX 98.iso / amiga_system / the_aminet / comm / tcp / slip_call30b1e.lha / SLIPCall30Eng / SLIPCall < prev    next >
Text File  |  1995-09-25  |  37KB  |  1,096 lines

  1. /* SLIPCall 3.0 beta 1 English                     */
  2. /*                                                 */
  3. /* Av Thomas Egrelius (thomas@fotoslide.bmc.uu.se) */
  4. /*                                                 */
  5.  
  6. if ~show('L', "rexxsupport.library") then
  7.     if ~addlib('rexxsupport.library', 0, -30, 0) then exit 41
  8. if ~show('L', "rexxserdev.library") then
  9.     if ~addlib('rexxserdev.library', 0, -30, 5) then exit 42
  10.  
  11. options results
  12. /*signal on error*/ /* Funkar inte med MBWatch */
  13. signal on halt
  14. signal on break_c
  15. signal on break_d
  16.  
  17. prefsfile = 'S:SLIPCall.config'
  18. qual1 = 'ctrl '
  19. qual2 = ''
  20. qual3 = ''
  21. key = 'f1'
  22. action = ''
  23. poll = 0
  24. win = 1
  25.  
  26. if arg() > 0 then do
  27.     do x = 1 to words(arg(1))
  28.         if upper(left(word(arg(1),x),2)) = '-C' then prefsfile = right(word(arg(1),x),wordlength(arg(1),x)-2)
  29.         if upper(left(word(arg(1),x),3)) = '-Q1' then qual1 = right(word(arg(1),x),wordlength(arg(1),x)-3)||' '
  30.         if upper(left(word(arg(1),x),3)) = '-Q2' then qual2 = right(word(arg(1),x),wordlength(arg(1),x)-3)||' '
  31.         if upper(left(word(arg(1),x),3)) = '-Q3' then qual3 = right(word(arg(1),x),wordlength(arg(1),x)-3)||' '
  32.         if upper(left(word(arg(1),x),2)) = '-K' then key = right(word(arg(1),x),wordlength(arg(1),x)-2)
  33.         if upper(left(word(arg(1),x),2)) = '-A' then action = upper(right(word(arg(1),x),wordlength(arg(1),x)-2))
  34.         if upper(left(word(arg(1),x),2)) = '-P' then poll = 1
  35.         if upper(left(word(arg(1),x),2)) = '-W' then win = 0
  36.     end
  37. end
  38.  
  39. if action ~= 'DIAL' & action ~= 'RESUME' & action ~= '' then do
  40.     say 'Wrong argument: -A'action
  41.     exit
  42. end
  43.  
  44. version = '$VER:SLIPCall 3.0b1e (25.9.95)'
  45. cr = '0d'x
  46.  
  47. /**************************************
  48.  ****   Definitioner av f÷nstren   ****
  49.  **************************************/
  50.  
  51. 'zInterface SLIPCall Hotkey="'qual1||qual2||qual3||key'" PersistFile="'prefsfile'"'
  52.     'zImage Magnify Width=11 Height=9 Depth=1 Data="3E006300C180C180C18063003EC000E00060"'
  53.     'zImage Folder  Width=11 Height=9 Depth=1 Data="7800840087E0F8208020802080208020FFE0"'
  54.  
  55. /*** Huvudf÷nster ***/
  56.  
  57.     'zWindow WMain Label "SLIPCall 3.0b1e: Hotkey = <'qual1||qual2||qual3||key'>" Open Centered CloseEvent ChildMaxWidth'
  58.         'zMenu Project'
  59.             'zObject Button MAbout Label "&About..." Cause "zDoMethod WAbout Open"'
  60.             'zObject Line'
  61.             'zObject Button MHide Label "&Hide" Cause "zDoMethod SLIPCall Deactivate"'
  62.             'zObject Button MQuit Label "&Quit" SelectEvent'
  63.         'zEndMenu'
  64.         'zMenu Action'
  65.             'zObject Button MRing Label "&Dial" SelectEvent"'
  66.             'zObject Button MResume Label "&Resume" SelectEvent'
  67.             'zObject Button MAvsluta Label "&Hangup" SelectEvent'
  68.         'zEndMenu'
  69.         'zMenu Preferences'
  70.             'zObject Button MPrefs Label "&Change..." SelectEvent'
  71.         'zEndMenu'
  72.  
  73.         'zGroup Horizontal'
  74.             'zGroup Vertical'
  75.                 'zObject TextDisplay IP NumColumns 40 Label "IP:"'
  76.                 'zObject TextDisplay HostName Numcolumns 40 Label "Name:"'
  77.                 'zObject TextDisplay Status Label "Status:" NumColumns 40 Value "Offline"'
  78.             'zEndGroup'
  79.             'zObject Line'
  80.             'zGroup Vertical ChildMaxWidth'
  81.                 'zObject Button BRing Label "&Dial" SelectEvent'
  82.                 'zObject Button BResume Label "&Resume" SelectEvent'
  83.                 'zObject Button BAvsluta Label "H&angup" SelectEvent'
  84.             'zEndGroup'
  85.         'zEndGroup'
  86.         'zObject Line'
  87.         'zGroup Horizontal'
  88.             'zObject Button BHide Label "&Hide" Cause "zDoMethod SLIPCall Deactivate"'
  89.             'zObject Button BPrefs Label "&Preferences..." SelectEvent'
  90.             'zObject Button BAbout Label "&About..." Cause "zDoMethod WAbout Open"'
  91.             'zObject Button BQuit Label "&Quit" SelectEvent'
  92.         'zEndGroup'
  93.     'zEndWindow'
  94.  
  95. /*** Aboutrequester ***/
  96.  
  97.     'zWindow WAbout Label "About SLIPCall..." NoClose Blocking Justification Center Alignment Center'
  98.         'zGroup Horizontal'
  99.             'zObject StdI Image Which=Information'
  100.             'zObject Line'
  101.             'zGroup Vertical ChildMaxWidth'
  102.                 'zObject TextDisplay A1 NoBorder Value "SLIPCall 3.0 beta 1 (1995-09-25)"'
  103.                 'zObject TextDisplay A4 NoBorder Value "English version"'
  104.                 'zObject TextDisplay A2 NoBorder Value "Copyright ⌐1995 Thomas Egrelius"'
  105.                 'zObject TextDisplay A3 NoBorder Value "email: egge@canit.se"'
  106.             'zEndGroup'
  107.         'zEndGroup'
  108.         'zObject Line'
  109.         'zObject Button AOK Label "   &OK   " Cause "zDoMethod WAbout Close"'
  110.     'zEndWindow'
  111.  
  112. /*** Varningsf÷nster ***/
  113.  
  114.     'zWindow WError Label "SLIPCall Message" NoClose Blocking Justification Center Alignment Center'
  115.         'zGroup Horizontal'
  116.             'zObject StdI Image Which=Exclamation'
  117.             'zObject Line'
  118.             'zGroup Vertical ChildMaxWidth'
  119.                 'zObject TextDisplay E1 NoBorder Value "Incorrect value!"'
  120.                 'zObject TextDisplay E2 NoBorder Value ""'
  121.                 'zObject TextDisplay E3 NoBorder Value ""'
  122.             'zEndGroup'
  123.         'zEndGroup'
  124.         'zObject Line'
  125.         'zObject Button EOK Label "   &OK   " Cause "zDoMethod WError Close"'
  126.     'zEndWindow'
  127.  
  128. /*** NoAmitcp f÷nster ***/
  129.  
  130.     'zWindow WFault Label "SLIPCall Message" NoClose Blocking Justification Center Alignment Center'
  131.         'zGroup Horizontal'
  132.             'zObject StdI Image Which=Stop'
  133.             'zObject Line'
  134.             'zGroup Vertical ChildMaxWidth'
  135.                 'zObject TextDisplay F1 NoBorder Value "Cannot find AmiTCP!"'
  136.                 'zObject TextDisplay F2 NoBorder Value "Quitting..."'
  137.             'zEndGroup'
  138.         'zEndGroup'
  139.         'zObject Line'
  140.         'zObject Button EOK Label "&Quit" SelectEvent'
  141.     'zEndWindow'
  142.  
  143. /*** Betainformation ***/
  144.  
  145.     'zWindow WBeta Label "SLIPCall Message" NoClose Blocking Justification Center Alignment Center'
  146.         'zGroup Horizontal'
  147.             'zObject StdI Image Which=Information'
  148.             'zObject Line'
  149.             'zGroup Vertical ChildMaxWidth'
  150.                 'zObject TextDisplay E1 NoBorder Value "This functions is not implemented yet."'
  151.             'zEndGroup'
  152.         'zEndGroup'
  153.         'zObject Line'
  154.         'zObject Button BOK Label "   &OK   " Cause "zDoMethod WBeta Close"'
  155.     'zEndWindow'
  156.  
  157. /***  InstΣllningar ***/
  158.  
  159.     'zWindow WPrefs Label "Preferences" NoClose Blocking ChildMaxWidth'
  160.         'zGroup Horizontal'
  161.             'zGroup Vertical'
  162.                 'zGroup Horizontal ChildMaxHeight'
  163.                     'zObject TextEntry PLogPath Persist Label "&Logpath:" MaxChars 100 NumColumns 32 Value "S:"'
  164.                     'zObject ButtonG PLogPathG Glyph=Folder UpEvent'
  165.                 'zEndGroup'
  166.                 'zObject TextEntry PPollcommand Persist Label "Poll&command:" MaxChars 64 NumColumns 32'
  167.                 'zObject TextEntry PUsername Persist Label "AmiTCP &user:" MaxChars 20 NumColumns 32 Value "<username>"'
  168.                 'zObject TextEntry PRetries Persist Label "&Retries:" MaxChars 3 NumColumns 32 Value "10" ChangeEvent'
  169.                 'zGroup Horizontal'
  170.                     'zObject Button PClock Label "Cloc&k" SelectEvent'
  171.                     'zObject TextEntry PClocktext Persist MaxChars 10 NumColumns 10 ChangeEvent Value "Show"'
  172.                 'zEndGroup'
  173.             'zEndGroup'
  174.             'zObject Line'
  175.             'zGroup Vertical ChildMaxWidth'
  176.                 'zObject Button PHost Label "&Provider" Cause "zDoMethod WPrefsHost Open"'
  177.                 'zObject Button PModem Label "&Modem" Cause "zDoMethod WPrefsModem Open"'
  178.                 'zObject Button PScript Label "S&cript" Cause "zDoMethod WPrefsScript Open"'
  179.             'zEndGroup'
  180.         'zEndGroup'
  181.         'zObject Line'
  182.         'zGroup Horizontal'
  183.             'zObject Button PSave Label "&Save" SelectEvent'
  184.             'zObject Button PSaveAs Label "Save &as..." SelectEvent'
  185.             'zObject Button PLoad Label "&Open..." SelectEvent'
  186.             'zObject Button PCancel Label "&Cancel" SelectEvent'
  187.         'zEndGroup'
  188.     'zEndWindow'
  189.  
  190. /*** InstΣllningar - Leverant÷r ***/
  191.  
  192.     'zWindow WPrefsHost Label "Provider Preferences" NoClose Blocking ChildMaxWidth'
  193.         'zObject TextEntry PHostName Persist Label "&Provider:" MaxChars 64 NumColumns 20'
  194.         'zObject TextEntry PPhone Persist Label "P&hone:" MaxChars 20 NumColumns 20'
  195.         'zObject TextEntry PDomain Persist Label "H&ostname:" MaxChars 32 NumColumns 20'
  196.         'zObject TextEntry PHostIP Persist Label "Host&IP:" MaxChars 15 NumColumns 20 Value "0.0.0.0"'
  197.         'zObject TextEntry PNameserver Persist Label "&Nameserver:" MaxChars 15 NumColumns 20 Value "0.0.0.0"'
  198.         'zObject TextEntry PGateway Persist Label "&Gateway:" MaxChars 15 NumColumns 20 Value "0.0.0.0"'
  199.         'zObject TextEntry PStatic Persist Label "Static IP:" MaxChars 15 NumColumns 20 Value "0.0.0.0"'
  200.         'zObject TextEntry PMTU Persist Label "&MTU:" MaxChars 4 NumColumns 20 Value "1500"'
  201.         'zObject Line'
  202.         'zGroup Horizontal'
  203.             'zObject Button PProtocol Label "&Protocol" SelectEvent'
  204.             'zObject TextEntry PPrototext Persist Value "CSLIP" NumColumns 10 ChangeEvent'
  205.             'zObject Button PDynamic Label "Address method" SelectEvent'
  206.             'zObject TextEntry PDyntext Persist Value "Dynamic" NumColumns 10 ChangeEvent'
  207.         'zEndGroup'
  208.         'zObject Line'
  209.         'zGroup Horizontal ChildMaxWidth'
  210.             'zObject Button HostOK Label "&Save" SelectEvent'
  211.             'zObject Button HostCancel Label "&Cancel" SelectEvent'
  212.         'zEndGroup'
  213.     'zEndWindow'
  214.  
  215. /*** InstΣllningar - Modem ***/
  216.  
  217.     'zWindow WPrefsModem Label "Modem Preferences" NoClose Blocking ChildMaxWidth'
  218.         'zObject TextEntry PInit Persist Label "Modem&Init:" MaxChars 64 NumColumns 20 Value "AT&F0&D0"'
  219.         'zObject TextEntry PReset Persist Label "Modem&Reset:" MaxChars 64 NumColumns 20 Value "ATZ"'
  220.         'zObject Line'
  221.         'zObject TextEntry PDevice Persist Label "&Device:" MaxChars 64 NumColumns 20 Value "serial.device"'
  222.         'zGroup Horizontal ChildMaxWidth Alignment Center'
  223.             'zGroup Vertical NoMargY ChildMaxWidth'
  224.                 'zObject Button PUnit Label "&Unit" SelectEvent'
  225.                 'zObject TextEntry PUnittext Persist MaxChars 1 NumColumns 10 ChangeEvent Value "0"'
  226.                 'zObject Button PSpeed Label "S&peed" SelectEvent'
  227.                 'zObject TextEntry PSpeedtext Persist MaxChars 6 NumColumns 10 ChangeEvent Value "38400"'
  228.                 'zObject Button PHShake Label "Hands&hake" SelectEvent'
  229.                 'zObject TextEntry PHShaketext Persist MaxChars 10 NumColumns 10 ChangeEvent Value "RTS/CTS"'
  230.             'zEndGroup'
  231.             'zObject Line'
  232.             'zGroup Vertical Align NoMargy ChildMaxWidth'
  233.                 'zObject Button PBits Label "Data&bits" SelectEvent'
  234.                 'zObject TextEntry PBitstext Persist MaxChars 1 NumColumns 10 ChangeEvent Value "8"'
  235.                 'zObject Button PParity Label "&Parity" SelectEvent'
  236.                 'zObject TextEntry PParitytext Persist MaxChars 10 NumColumns 10 ChangeEvent Value "None" '
  237.                 'zObject Button PStops Label "Stopbi&ts" SelectEvent'
  238.                 'zObject TextEntry PStopstext Persist MaxChars 1 NumColumns 1 ChangeEvent Value "1"'
  239.             'zEndGroup'
  240.         'zEndGroup'
  241.         'zObject Line'
  242.         'zGroup Horizontal ChildMaxWidth'
  243.             'zObject Button ModemOK Label "&Save" SelectEvent'
  244.             'zObject Button ModemCancel Label "&Cancel" SelectEvent'
  245.         'zEndGroup'
  246.     'zEndWindow'
  247.  
  248. /*** InstΣllningar - Script ***/
  249.  
  250.     'zWindow WPrefsScript Label "Login Script" Blocking ChildMaxWidth'
  251.         'zGroup Horizontal ChildMaxHeight'
  252.             'zObject Button SB1 Label "W/S" SelectEvent'
  253.             'zObject TextEntry ST1 Persist MaxChars 8 NumColumns 8 ChangeEvent Value "Wait for"'
  254.             'zObject TextEntry S1 Persist MaxChars 64 NumColumns 30'
  255.         'zEndGroup'
  256.         'zGroup Horizontal ChildMaxHeight'
  257.             'zObject Button SB2 Label "W/S" SelectEvent'
  258.             'zObject TextEntry ST2 Persist MaxChars 8 NumColumns 8 ChangeEvent Value "Send"'
  259.             'zObject TextEntry S2 Persist MaxChars 64 NumColumns 30'
  260.         'zEndGroup'
  261.         'zGroup Horizontal ChildMaxHeight'
  262.             'zObject Button SB3 Label "W/S" SelectEvent'
  263.             'zObject TextEntry ST3 Persist MaxChars 8 NumColumns 8 ChangeEvent Value "Wait for"'
  264.             'zObject TextEntry S3 Persist MaxChars 64 NumColumns 30'
  265.         'zEndGroup'
  266.         'zGroup Horizontal ChildMaxHeight'
  267.             'zObject Button SB4 Label "W/S" SelectEvent'
  268.             'zObject TextEntry ST4 Persist MaxChars 8 NumColumns 8 ChangeEvent Value "Send"'
  269.             'zObject TextEntry S4 Persist MaxChars 64 NumColumns 30'
  270.         'zEndGroup'
  271.         'zGroup Horizontal ChildMaxHeight'
  272.             'zObject Button SB5 Label "W/S" SelectEvent'
  273.             'zObject TextEntry ST5 Persist MaxChars 8 NumColumns 8 ChangeEvent Value "Wait for"'
  274.             'zObject TextEntry S5 Persist MaxChars 64 NumColumns 30'
  275.         'zEndGroup'
  276.         'zGroup Horizontal ChildMaxHeight'
  277.             'zObject Button SB6 Label "W/S" SelectEvent'
  278.             'zObject TextEntry ST6 Persist MaxChars 8 NumColumns 8 ChangeEvent Value "Send"'
  279.             'zObject TextEntry S6 Persist MaxChars 64 NumColumns 30'
  280.         'zEndGroup'
  281.         'zGroup Horizontal ChildMaxHeight'
  282.             'zObject Button SB7 Label "W/S" SelectEvent'
  283.             'zObject TextEntry ST7 Persist MaxChars 8 NumColumns 8 ChangeEvent Value "Wait for"'
  284.             'zObject TextEntry S7 Persist MaxChars 64 NumColumns 30'
  285.         'zEndGroup'
  286.         'zGroup Horizontal ChildMaxHeight'
  287.             'zObject Button SB8 Label "W/S" SelectEvent'
  288.             'zObject TextEntry ST8 Persist MaxChars 8 NumColumns 8 ChangeEvent Value "Send"'
  289.             'zObject TextEntry S8 Persist MaxChars 64 NumColumns 30'
  290.         'zEndGroup'
  291.         'zGroup Horizontal ChildMaxHeight'
  292.             'zObject Button SB9 Label "W/S" SelectEvent'
  293.             'zObject TextEntry ST9 Persist MaxChars 8 NumColumns 8 ChangeEvent Value "Wait for"'
  294.             'zObject TextEntry S9 Persist MaxChars 64 NumColumns 30'
  295.         'zEndGroup'
  296.         'zGroup Horizontal ChildMaxHeight'
  297.             'zObject Button SB10 Label "W/S" SelectEvent'
  298.             'zObject TextEntry ST10 Persist MaxChars 8 NumColumns 8 ChangeEvent Value "Send"'
  299.             'zObject TextEntry S10 Persist MaxChars 64 NumColumns 30'
  300.         'zEndGroup'
  301.         'zObject Line'
  302.         'zGroup Horizontal ChildMaxWidth'
  303.             'zObject Button ScriptOK Label "&Save" SelectEvent'
  304.             'zObject Button ScriptCancel Label "&Cancel" SelectEvent'
  305.         'zEndGroup'
  306.     'zEndWindow'
  307. 'zEndInterface'
  308.  
  309. /*** Starta upp... ***/
  310.  
  311. if ~exists('AmiTCP:') then do
  312.     'zDoMethod WFault Open'
  313.     call run()
  314. end
  315.  
  316. flags.call = 0
  317. flags.serclosed = 1
  318. flags.tcponline = 0
  319.  
  320. if win then 'zDoMethod SLIPCall Activate'
  321.  
  322. call Initialize()
  323.  
  324. if poll then do
  325.     prefs.clock = 0
  326.     call MRing_Select()
  327.     address command prefs.pollcommand
  328.     call MQuit_Select()
  329. end
  330.  
  331. if action = 'DIAL' then call MRing_Select()
  332. if action = 'RESUME' then call MResume_Select()
  333.  
  334. run:
  335. do forever
  336.     'zWaitForEvent stem.'
  337.     interpret "zRC="RESULT"()"
  338. end
  339.  
  340. /*** Funktioner som hanterar GUI events ***/
  341.  
  342. /*** Avsluta ***/
  343.  
  344. halt:
  345. break_c:
  346. MQuit_Select:
  347. BQuit_Select:
  348. WMain_Close:
  349. SLIPCall_Quit:
  350.     call MAvsluta_Select()
  351.     exit
  352.  
  353. break_d:
  354.     call MAvsluta_Select()
  355.     return 0
  356.  
  357. EOK_Select:
  358.     'zDoMethod WFault Close'
  359.     exit
  360.  
  361. Error:
  362.     call MAvsluta_Select()
  363.     if rc=20 then do
  364.         say "Must be run with zrx!"
  365.         exit
  366.     end
  367.     say "Error" RC "at line" SIGL " (errnum="zErrNum")"
  368.     exit
  369.  
  370. BPrefs_Select:
  371. MPrefs_Select:
  372.     if connected ~= 1 then 'zDoMethod WPrefs Open'
  373.     return 0
  374.  
  375. /*** Ring ***/
  376.  
  377. BRing_Select:
  378. MRing_Select:
  379.     flags.call = 1
  380.     dh = SerOpen(prefs.device, prefs.unit)
  381.     if (dh == 0) then do
  382.         'zSetAttr E1 Value "Serious Error!"'
  383.         'zSetAttr E2 Value ""'
  384.         'zSetAttr E3 Value "Cannot open 'prefs.device'"'
  385.         'zDoMethod WError Open'
  386.         return 0
  387.     end
  388.  
  389.     flags.serclosed = 0
  390.     check     = SerClear(dh)
  391.     check     = SerSetParms(dh, prefs.speed, prefs.databits, prefs.paritet, prefs.stopbits, prefs.handshake, 250000, 4096)
  392.     buffer    = AllocMem(4096)
  393.     junk      = c2d(buffer)
  394.     check     = 0
  395.     connected = 0
  396.  
  397.     SerWrite(dh, prefs.modeminit, length(prefs.modeminit))
  398.     do x = 1 to prefs.retries
  399.         'zSetAttr Status Value "Dialing '||prefs.hostname||',  ('||x||' of '||prefs.retries||')."'
  400.         do forever
  401.             Delay(100)
  402.             if (check == 0) then do
  403.                 result = SerWrite(dh, 'ATDT'||prefs.hostphone||cr, length('ATDT'||prefs.hostphone||cr))
  404.                 check = 1
  405.                 totalstr = ''
  406.             end
  407.             status = SerQuery(dh)
  408.             parse upper var status valid bytes_read .
  409.             rcvdstrg = SerRead(dh, junk, bytes_read)
  410.             totalstr = totalstr||rcvdstrg
  411.             check = modem_query(totalstr)
  412.             check2 = 0
  413.             if (check == 100) then leave
  414.             if (check == 101) then do; check = 0; check2 = 1; 'zSetAttr Status Value "Busy..."'; Delay(100); end
  415.             if (check == 102) then do; check = 0; check2 = 1; 'zSetAttr Status Value "No carrier..."'; Delay(100); end
  416.             if (check == 103) then do; check = 0; check2 = 1; 'zSetAttr Status Value "No answer..."'; Delay(100); end
  417.             if check2 then leave
  418.         end
  419.         if (check == 100) then leave
  420.     end
  421.  
  422.     if check ~= 100 then do; call CloseSer(); 'zSetAttr Status Value "Offline"'; return 0; end
  423.     connected = 1
  424.     parse var totalstr .'CONNECT ' linespeed+5 +2 totalstr
  425.     if prefs.clock then do
  426.         if ~show('p', 'MBWATCH.01') then address command 'run >NIL: <NIL: mbwatch start logtime 10'
  427.         else do
  428.             address mbwatch.01 reset
  429.             address mbwatch.01 start
  430.         end
  431.     end
  432.     'zSetAttr Status Value "Connected to 'prefs.hostname' at 'linespeed' bps."'
  433.     if ~exists(prefs.logpath) then do
  434.         call Open(logfile, prefs.logpath, 'W')
  435.         writeln(logfile, '')
  436.         call Close(logfile)
  437.     end
  438.     if Open(logfile, prefs.logpath, 'A') then do
  439.         writeln(logfile, '')
  440.         writeln(logfile, date()||' '||time()||'  Connected to '||prefs.hostname||' at '||prefs.hostphone)
  441.         call Close(logfile)
  442.     end
  443.  
  444.     call login()
  445.  
  446.     return 0
  447.  
  448. /*** ┼teruppta ***/
  449.  
  450. BResume_Select:
  451. MResume_Select:
  452.     if exists('ENVARC:ip') then do
  453.         slipip = 0
  454.         if Open(file, 'ENVARC:ip', 'R') then do
  455.             slipip = readln(file)
  456.             slipip = slipip||'  '
  457.             call Close(file)
  458.         end
  459.         if prefs.clock then do
  460.             if ~show('P', 'MBWATCH.01') then address command 'run >NIL: <NIL: mbwatch logtime 10'
  461.             address 'MBWATCH.01' 'START'
  462.         end
  463.         'zSetAttr Status Value "Trying to resume connection to 'prefs.hostname'..."'
  464.         address command 'copy ENVARC:ip ENV:ip'
  465.         if ~exists('ENV:Sana2') then address command 'makedir ENV:Sana2'
  466.         address command 'echo >ENV:Sana2/rhslip0.config "'prefs.device prefs.unit prefs.speed '$ip MTU='prefs.mtu' 7WIRE"'
  467.         if ip ~= 0 then 'zSetAttr IP Value "'||left(slipip,length(slipip)-2)'"'
  468.         call startnet()
  469.         connected = 1
  470.     end
  471.     else do
  472.         'zSetAttr Status Value "Cannot resume lost connection!"'
  473.         Delay(300)
  474.         flags.call = 1
  475.         connected = 1
  476.         call hangup()
  477.     end
  478.     return 0
  479.  
  480. /*** LΣgg pσ ***/
  481.  
  482. BAvsluta_Select:
  483. MAvsluta_Select:
  484.     if connected = 1 then do
  485.         'zSetAttr Status Value "Finnishing connection..."'
  486.         if flags.tcponline then do
  487.             address command 'AmiTCP:bin/offline 'prefs.slipdevice
  488.             flags.tcponline = 0
  489.         end
  490.         Delay(100)
  491.         if flags.serclosed then do
  492.             dh = SerOpen(prefs.device, prefs.unit)
  493.             flags.serclosed = 0
  494.             check = SerClear(dh)
  495.             check = SerSetParms(dh, prefs.speed, prefs.databits, prefs.paritet, prefs.stopbits)
  496.         end
  497.         call hangup()
  498.         if show('P', 'AMITCP') then address 'AMITCP' 'KILL'
  499.  
  500.         'zSetAttr IP Value " "'
  501.         'zSetAttr HostName Value " "'
  502.         'zSetAttr Status Value "Offline"'
  503.     end
  504.     return 0
  505.  
  506. /*** InstΣllningar - AnvΣnd ***/
  507.  
  508. PSave_Select:
  509.     'zDoMethod WPrefs Save'
  510.     'zDoMethod WPrefs Close'
  511.     call Initialize()
  512.     return 0
  513.  
  514. /*** InstΣllningar - Spara som... ***/
  515.  
  516. PSaveAs_Select:
  517.     'zDoMethod WBeta Open'
  518.     return 0
  519.  
  520. /*** InstΣllningar - Ladda ***/
  521.  
  522. PLoad_Select:
  523.     'zDoMethod WBeta Open'
  524.     return 0
  525.  
  526. /*** InstΣllningar - Avbryt ***/
  527.  
  528. PCancel_Select:
  529.     'zDoMethod WPrefs Restore'
  530.     'zDoMethod WPrefs Close'
  531.     call initialize()
  532.     return 0
  533.  
  534. PProtocol_Select:
  535.  
  536.     'zGetAttr PPrototext Value'
  537.     if result = "CSLIP" then 'zSetAttr PPrototext Value "SLIP"'
  538.     else 'zSetAttr PPrototext Value "CSLIP"'
  539.     return 0
  540.  
  541. PPrototext_Change:
  542.     'zGetAttr PPrototext Value'
  543.     value = result
  544.     if upper(result) ~= "CSLIP" & upper(result) ~= "SLIP" then do
  545.         'zSetAttr E1 Value "Incorrect value!"'
  546.         'zSetAttr E2 Value ""'
  547.         'zSetAttr E3 Value "Protocol: 'value'"'
  548.         'zDoMethod WError Open'
  549.         'zSetAttr PPrototext Value "CSLIP"'
  550.     end
  551.     return 0
  552.  
  553. PDynamic_Select:
  554.     'zGetAttr PDyntext Value'
  555.     if upper(result) = "DYNAMIC" then 'zSetAttr PDyntext Value "Static"'
  556.     else 'zSetAttr PDyntext Value "Dynamic"'
  557.     return 0
  558.  
  559. PDyntext_Change:
  560.     'zGetAttr PDyntext Value'
  561.     value = result
  562.     if upper(result) ~= "DYNAMIC" & upper(result) ~= "STATIC" then do
  563.         'zSetAttr E1 Value "Incorrect value"'
  564.         'zSetAttr E2 Value ""'
  565.         'zSetAttr E3 Value "Address method: 'value'"'
  566.         'zDoMethod WError Open'
  567.         'zSetAttr PDyntext Value "Dynamic"'
  568.     end
  569.     return 0
  570.  
  571. PUnit_Select:
  572.     'zGetAttr PUnittext Value'
  573.     enhet = result + 1
  574.     if enhet > 9 then enhet = 0
  575.     'zSetAttr PUnittext Value "'||enhet||'"'
  576.     return 0
  577.  
  578. PUnittext_Change:
  579.     'zGetAttr PUnittext Value'
  580.     value = result
  581.     if result < "0" | result > "9" then do
  582.         'zSetAttr E1 Value "Incorrect value!"'
  583.         'zSetAttr E2 Value ""'
  584.         'zSetAttr E3 Value "Unit: 'value'"'
  585.         'zDoMethod WError Open'
  586.         'zSetAttr PUnittext Value "0"'
  587.     end
  588.     return 0
  589.  
  590. PSpeed_select:
  591.     'zGetAttr PSpeedtext Value'
  592.     hastighet = result
  593.     if hastighet = "115200" then hastighet = "1200"
  594.     if hastighet = "57600" then hastighet = "115200"
  595.     if hastighet = "38400" then hastighet = "57600"
  596.     if hastighet = "19200" then hastighet = "38400"
  597.     if hastighet = "14400" then hastighet = "19200"
  598.     if hastighet = "9600" then hastighet = "14400"
  599.     if hastighet = "2400" then hastighet = "9600"
  600.     if hastighet = "1200" then hastighet = "2400"
  601.     'zSetAttr PSpeedtext Value "'||hastighet||'"'
  602.     return 0
  603.  
  604. PSpeedtext_Change:
  605.     'zGetAttr PSpeedtext Value'
  606.     value = result
  607.     if result ~= "115200" & result ~= "57600" & result ~= "38400" & result ~= "19200" & result ~= "14400" & result ~= "9600" & result ~= "2400" then do
  608.         'zSetAttr E1 Value "Incorrect value!"'
  609.         'zSetAttr E2 Value ""'
  610.         'zSetAttr E3 Value "Speed: 'value'"'
  611.         'zDoMethod WError Open'
  612.         'zSetAttr PSpeedtext Value "38400"'
  613.     end
  614.     return 0
  615.  
  616. PHShake_Select:
  617.     'zGetAttr PHShaketext Value'
  618.     handshake = result
  619.     if handshake = "RTS/CTS" then handshake = "XON/XOFF"
  620.     else handshake = "RTS/CTS"
  621.     'zSetAttr PHShaketext Value "'||handshake||'"'
  622.     return 0
  623.  
  624. PHShaketext_Change:
  625.     'zGetAttr PHShaketext Value'
  626.     value = result
  627.     if upper(result) ~= "RTS/CTS" & upper(result) ~= "XON/XOFF" then do
  628.         'zSetAttr E1 Value "Incorrect value!"'
  629.         'zSetAttr E2 Value ""'
  630.         'zSetAttr E3 Value "Handshake: 'value'"'
  631.         'zDoMethod WError Open'
  632.         'zSetAttr PHShaketext Value "RTS/CTS"'
  633.     end
  634.     return 0
  635.  
  636. PBits_Select:
  637.     'zGetAttr PBitstext Value'
  638.     bits = result +1
  639.     if bits > 8 then bits = 1
  640.     'zSetAttr PBitstext Value "'||bits||'"'
  641.     return 0
  642.  
  643. PBitstext_Change:
  644.     'zGetAttr PBitstext Value'
  645.     value = result
  646.     if result < "1" | result > "8" then do
  647.         'zSetAttr E1 Value "Incorrect value!"'
  648.         'zSetAttr E2 Value ""'
  649.         'zSetAttr E3 Value "Databits: 'value'"'
  650.         'zDoMethod WError Open'
  651.         'zSetAttr PBitstext Value "8"'
  652.     end
  653.     return 0
  654.  
  655. PParity_Select:
  656.     'zGetAttr PParitytext Value'
  657.     paritet = result
  658.     if paritet = "Space" then paritet = "X"
  659.     if paritet = "Mark" then paritet = "Space"
  660.     if paritet = "Odd" then paritet = "Mark"
  661.     if paritet = "Even" then paritet = "Odd"
  662.     if paritet = "None" then paritet = "Even"
  663.     if paritet = "X" then paritet = "None"
  664.     'zSetAttr PParitytext Value "'||paritet||'"'
  665.     return 0
  666.  
  667. PParitytext_Change:
  668.     'zGetAttr PParitytext Value'
  669.     value = result
  670.     if upper(result) ~= "SPACE" & upper(result) ~= "MARK" & upper(result) ~= "ODD" & upper(result) ~= "EVEN" & upper(result) ~= "NONE" then do
  671.         'zSetAttr E1 Value "Incorrect value!"'
  672.         'zSetAttr E2 Value ""'
  673.         'zSetAttr E3 Value "Parity: 'value'"'
  674.         'zDoMethod WError Open'
  675.         'zSetAttr PParitytext Value "None"'
  676.     end
  677.     return 0
  678.  
  679. PStops_Select:
  680.     'zGetAttr PStopstext Value'
  681.     stopbits = result + 1
  682.     if stopbits > 2 then stopbits = 1
  683.     'zSetAttr PStopstext Value "'||stopbits||'"'
  684.     return 0
  685.  
  686. PStopstext_Change:
  687.     'zGetAttr PStopstext Value'
  688.     value = result
  689.     if result < "1" | result > "2" then do
  690.         'zSetAttr E1 Value "Incorrect value!"'
  691.         'zSetAttr E2 Value ""'
  692.         'zSetAttr E3 Value "Stopbits: 'value'"'
  693.         'zDoMethod WError Open'
  694.         'zSetAttr PStopstext Value "1"'
  695.     end
  696.     return 0
  697.  
  698. SB1_Select:
  699.     call ScriptChangeValue(ST1)
  700.     return 0
  701.  
  702. ST1_Change:
  703.     call ScriptCheckValue(ST1)
  704.     return 0
  705.  
  706. SB2_Select:
  707.     call ScriptChangeValue(ST2)
  708.     return 0
  709.  
  710. ST2_Change:
  711.     call ScriptCheckValue(ST2)
  712.     return 0
  713.  
  714. SB3_Select:
  715.     call ScriptChangeValue(ST3)
  716.     return 0
  717.  
  718. ST3_Change:
  719.     call ScriptCheckValue(ST3)
  720.     return 0
  721.  
  722. SB4_Select:
  723.     call ScriptChangeValue(ST4)
  724.     return 0
  725.  
  726. ST4_Change:
  727.     call ScriptCheckValue(ST4)
  728.     return 0
  729.  
  730. SB5_Select:
  731.     call ScriptChangeValue(ST5)
  732.     return 0
  733.  
  734. ST5_Change:
  735.     call ScriptCheckValue(ST5)
  736.     return 0
  737.  
  738. SB6_Select:
  739.     call ScriptChangeValue(ST6)
  740.     return 0
  741.  
  742. ST6_Change:
  743.     call ScriptCheckValue(ST6)
  744.     return 0
  745.  
  746. SB7_Select:
  747.     call ScriptChangeValue(ST7)
  748.     return 0
  749.  
  750. ST7_Change:
  751.     call ScriptCheckValue(ST7)
  752.     return 0
  753.  
  754. SB8_Select:
  755.     call ScriptChangeValue(ST8)
  756.     return 0
  757.  
  758. ST8_Change:
  759.     call ScriptCheckValue(ST8)
  760.     return 0
  761.  
  762. SB9_Select:
  763.     call ScriptChangeValue(ST9)
  764.     return 0
  765.  
  766. ST9_Change:
  767.     call ScriptCheckValue(ST9)
  768.     return 0
  769.  
  770. SB10_Select:
  771.     call ScriptChangeValue(ST10)
  772.     return 0
  773.  
  774. ST10_Change:
  775.     call ScriptCheckValue(ST10)
  776.     return 0
  777.  
  778. PRetries_Change:
  779.     'zGetAttr PRetries Value'
  780.     value = result
  781.     if ~datatype(value, 'N') then do
  782.         'zSetAttr E1 Value "Incorrect value!"'
  783.         'zSetAttr E2 Value ""'
  784.         'zSetAttr E3 Value "Retries: 'value'"'
  785.         'zDoMethod WError Open'
  786.         'zSetAttr PRetries Value "20"'
  787.     end
  788.     return 0
  789.  
  790. PClock_Select:
  791.     'zGetAttr PClocktext Value'
  792.     if upper(result) = "SHOW" then 'zSetAttr PClocktext Value "Hide"'
  793.     else 'zSetAttr PClocktext Value "Show"'
  794.     return 0
  795.  
  796. PClocktext_Change:
  797.     'zGetAttr PClocktext Value'
  798.     value = result
  799.     if upper(result) ~= "SHOW" & upper(result) ~= "HIDE" then do
  800.         'zSetAttr E1 Value "Incorrect value!"'
  801.         'zSetAttr E2 Value ""'
  802.         'zSetAttr E3 Value "Clock: 'value'"'
  803.         'zDoMethod WError Open'
  804.         'zSetAttr PClocktext Value "Show"'
  805.     end
  806.     return 0
  807.  
  808. PLogPathG_Change:
  809.     'zGetAttr PLogPath Value'
  810.     'zRequest Directory Label "Choose path for the logfile:" Value "'result'"'
  811.     'zSetAttr PLogPath Value "'||result||'"'
  812.     return 0
  813.  
  814. HostOK_Select:
  815.     'zDoMethod WPrefsHost Save'
  816.     'zDoMethod WPrefsHost Close'
  817.     return 0
  818.  
  819. HostCancel_Select:
  820.     'zDoMethod WPrefsHost Restore'
  821.     'zDoMethod WPrefsHost Close'
  822.     return 0
  823.  
  824. ModemOK_Select:
  825.     'zDoMethod WPrefsModem Save'
  826.     'zDoMethod WPrefsModem Close'
  827.     return 0
  828.  
  829. ModemCancel_Select:
  830.     'zDoMethod WPrefsModem Restore'
  831.     'zDoMethod WPrefsModem Close'
  832.     return 0
  833.  
  834. ScriptOK_Select:
  835.     'zDoMethod WPrefsScript Save'
  836.     'zDoMethod WPrefsScript Close'
  837.     return 0
  838.  
  839. ScriptCancel_Select:
  840.     'zDoMethod WPrefsScript Restore'
  841.     'zDoMethod WPrefsScript Close'
  842.     return 0
  843.  
  844.  
  845.  
  846.  
  847.  
  848. ScriptChangeValue:
  849.     parse arg gadget
  850.  
  851.     'zGetAttr 'gadget' Value'
  852.     if upper(result) = "WAIT FOR" then 'zSetAttr 'gadget' Value "Send"'
  853.     else 'zSetAttr 'gadget' Value "Wait for"'
  854.     return 0
  855.  
  856. ScriptCheckValue:
  857.     parse arg gadget
  858.  
  859.     'zGetAttr 'gadget' Value'
  860.     value = result
  861.     if upper(result) ~= "WAIT FOR" & upper(result) ~= "SEND" then do
  862.         'zSetAttr E1 Value "Incorrect value!"'
  863.         'zSetAttr E2 Value ""'
  864.         'zSetAttr E3 Value "Script: 'value'"'
  865.         'zDoMethod WError Open'
  866.         'zSetAttr 'gadget' Value "Wait for"'
  867.     end
  868.     return 0
  869.  
  870.  
  871. Initialize:
  872.     'zSetAttr Status Value "Initializing SLIPCall..."'
  873.     'zGetAttr PLogPath Value'
  874.     prefs.logpath = result'SLIPCalls.log'
  875.     'zGetAttr PPollcommand Value'
  876.     prefs.pollcommand = result
  877.     'zGetAttr PUsername Value'
  878.     prefs.username = result
  879.     'zGetAttr PClocktext Value'
  880.     if upper(result) = "SHOW" then prefs.clock = "1"
  881.     else prefs.clock = "0"
  882.     'zGetAttr PRetries Value'
  883.     prefs.retries = result
  884.     'zGetAttr PHostName Value'
  885.     prefs.hostname = result
  886.     'zGetAttr PPhone Value'
  887.     prefs.hostphone = result
  888.     'zGetAttr PDomain Value'
  889.     prefs.hostdomain = result
  890.     'zGetAttr PHostIP Value'
  891.     prefs.hostip = result
  892.     'zGetAttr PNameserver Value'
  893.     prefs.nameserver = result
  894.     'zGetAttr PGateway Value'
  895.     prefs.gateway = result
  896.     'zGetAttr PStatic Value'
  897.     prefs.statisk = result
  898.     'zGetAttr PMTU Value'
  899.     prefs.mtu = result
  900.     'zGetAttr PPrototext Value'
  901.     prefs.protokoll = upper(result)
  902.     prefs.slipdevice = 'rhslip.device 0'
  903.     prefs.sanadriver = 'slip0'
  904.     if prefs.protokoll = 'CSLIP' then do
  905.         prefs.slipdevice = 'rhcslip.device 0'
  906.         prefs.sanadriver = 'cslip0'
  907.     end
  908.     'zgetAttr PDyntext Value'
  909.     prefs.adressering = upper(result)
  910.     'zGetAttr PInit Value'
  911.     prefs.modeminit = upper(result)||cr
  912.     'zGetAttr PReset Value'
  913.     prefs.modemreset = upper(result)||cr
  914.     'zGetAttr PDevice Value'
  915.     prefs.device = result
  916.     'zGetAttr PUnittext Value'
  917.     prefs.unit = result
  918.     'zGetAttr PSpeedtext Value'
  919.     prefs.speed = result
  920.     'zGetAttr PHShaketext Value'
  921.     if upper(result) = "RTS/CTS" then prefs.handshake = "0"
  922.     else prefs.handshake = "1"
  923.     'zGetAttr PBitstext Value'
  924.     prefs.databits = result
  925.     'zGetAttr PParitytext Value'
  926.     prefs.paritet = "N"
  927.     if upper(result) = "EVEN" then prefs.paritet = "E"
  928.     if upper(result) = "ODD" then prefs.paritet = "O"
  929.     if upper(result) = "MARK" then prefs.paritet = "M"
  930.     if upper(result) = "SPACE" then prefs.paritet = "S"
  931.     'zGetAttr PStopstext Value'
  932.     prefs.stopbits = result
  933.     do x = 1 to 10
  934.         'zGetAttr ST'||x||' Value'
  935.         if upper(result) = "WAIT FOR" then event.x = "WAIT"
  936.         else event.x = "SEND"
  937.         'zGetAttr S'||x||' Value'
  938.         if result ~= 'RESULT' then string.x = result
  939.         else string.x = ''
  940.     end
  941.  
  942.     /*** Konfigurera AmiTCP ***/
  943.  
  944.     if ~exists('AmiTCP:db/resolv.conf.bkup') then do
  945.         if exists('AmiTCP:db/resolv.conf') then address command 'rename AmiTCP:db/resolv.conf as AmiTCP:db/resolv.conf.bkup'
  946.     end
  947.     address command 'echo >AmiTCP:db/resolv.conf "DOMAIN 'prefs.hostdomain'"'
  948.     address command 'echo >>AmiTCP:db/resolv.conf "NAMESERVER 'prefs.nameserver'"'
  949.  
  950.     'zSetAttr Status Value "Offline"'
  951.  
  952.     return 0
  953.  
  954. login:
  955.     SerWrite(dh, cr, length(cr))
  956.     do x=1 to 10
  957.         if string.x ~= '' then do
  958.             if event.x = "WAIT" then waitresult = wait_str(string.x)
  959.             if event.x = "SEND" then SerWrite(dh, string.x||cr, length(string.x||cr))
  960.         end
  961.         else leave
  962.         if waitresult = 10 then do
  963.             call FreeMem(buffer, 4096)
  964.             return 0
  965.         end
  966.     end
  967.     SerClose(dh)
  968.     flags.serclosed = 1
  969.  
  970.     laststring = x - 1
  971.     parse var rcvdstr . (string.laststring) ' ' a '.' b '.' c '.' d .
  972.     if prefs.adressering = "DYNAMIC" then slipip = a||'.'||b||'.'||c||'.'||d
  973.     else slipip = prefs.statisk||'  '
  974.     'zSetAttr IP Value "'||left(slipip, length(slipip)-2)||'   ('time()', 'date()')"'
  975.     address command 'echo >ENV:ip '||left(slipip, length(slipip)-2)
  976.     address command 'echo >ENVARC:ip '||left(slipip, length(slipip)-2)
  977.  
  978.     /*** Skapa ENV:Sana2/rhslip0.config ***/
  979.  
  980.     if ~exists('ENV:Sana2') then address command 'makedir ENV:Sana2'
  981.     address command 'echo >ENV:Sana2/rhslip0.config "'prefs.device prefs.unit prefs.speed '$ip MTU='prefs.mtu' 7WIRE"'
  982.  
  983.     call startnet()
  984.  
  985.     call FreeMem(buffer, 4096)
  986.     return 0
  987.  
  988. wait_str:
  989.   teststr = arg(1)
  990.   check = 0
  991.   timeout = 0
  992.   do until (check ~= 0)
  993.       status   = SerQuery(dh)
  994.       parse upper var status valid bytes_read .
  995.       rcvdstr  = SerRead(dh, junk, bytes_read)
  996.       totalstr = totalstr||rcvdstr
  997.       check    = pos(teststr,totalstr)
  998.       timeout = timeout + 1
  999.       if timeout = 100 then check = -1
  1000.       Delay(20)
  1001.    end
  1002.    if check = -1 then do
  1003.       'zSetAttr Status Value "Timeout when waiting for string. Hanging up!"'
  1004.       Delay(100)
  1005.       call MAvsluta_Select()
  1006.       return 10
  1007.    end
  1008.    rcvdstr  = totalstr
  1009.    totalstr = ''
  1010. return 0
  1011.  
  1012. modem_query:
  1013.    teststr = arg(1)
  1014.    if (pos('CONNECT'   , teststr) ~= 0) then return 100
  1015.    if (pos('BUSY'      , teststr) ~= 0) then return 101
  1016.    if (pos('NO CARRIER', teststr) ~= 0) then return 102
  1017.    if (pos('NO ANSWER' , teststr) ~= 0) then return 103
  1018. return 200
  1019.  
  1020. CloseSer:
  1021.     call SerClose(dh)
  1022.     flags.serclosed = 1
  1023.     return 0
  1024.  
  1025. hangup:
  1026.     if flags.call then do
  1027.         if connected ~= 0 then do
  1028.             'zSetAttr Status Value "Hanging up..."'
  1029.             if flags.serclosed then do
  1030.                 dh = SerOpen(prefs.device, prefs.unit)
  1031.                 if (dh == 0) then do
  1032.                     'zSetAttr E1 Value "Serious Error!"'
  1033.                     'zSetAttr E2 Value ""'
  1034.                     'zSetAttr E3 Value "Cannot open 'prefs.device'"'
  1035.                     'zDoMethod WError Open'
  1036.                     return 0
  1037.                 end
  1038.  
  1039.                 check     = SerClear(dh)
  1040.                 check     = SerSetParms(dh, prefs.speed, prefs.databits, prefs.paritet, prefs.stopbits, prefs.handshake, 250000, 4096)
  1041.             end
  1042.             check = SerWrite(dh, '+++', 3)
  1043.             check = Delay(100)
  1044.             check = SerWrite(dh, 'ATH0'||cr, 5)
  1045.  
  1046.             if Open(logfile, prefs.logpath, 'A') then do
  1047.                 call writeln(logfile, date()||' '||time()||'  Connection finnished')
  1048.                 call Close(logfile)
  1049.             end
  1050.             connected = 0
  1051.         end
  1052.         if prefs.clock then address 'MBWATCH.01' 'QUIT'
  1053.         Delay(300)
  1054.         SerWrite(dh, prefs.modemreset||cr, length(prefs.modemreset||cr))
  1055.         Delay(100)
  1056.         call SerClose(dh)
  1057.         flags.serclosed = 1
  1058.         flags.call = 0
  1059.     end
  1060.     return 0
  1061.  
  1062. GetHostName:
  1063.     name = '½Unknown╗'
  1064.     address command "AmiTCP:bin/hostname >T:actualname"
  1065.     if Open(file, 'T:actualname', 'R') then do
  1066.         name = readln(file)
  1067.         call Close(file)
  1068.     end
  1069.     'zSetAttr HostName Value "'name'"'
  1070.     return 0
  1071.  
  1072. startnet:
  1073.     'zSetAttr Status Value "Starting AmiTCP..."'
  1074.     address command
  1075.     'AmiTCP:bin/login -f 'prefs.username
  1076.     'AmiTCP:bin/umask 022'
  1077.     'AmiTCP:AmiTCP >NIL:'
  1078.     'SYS:Rexxc/WaitForPort AMITCP >NIL:'
  1079.     'AmiTCP:bin/ifconfig lo0 localhost'
  1080.     'AmiTCP:bin/ifconfig '||prefs.sanadriver||' '||left(slipip, length(slipip)-2)||' '||prefs.hostip||' netmask 255.255.255.0'
  1081.     'AmiTCP:bin/route add '||left(slipip, length(slipip)-2)||' localhost'
  1082.     'AmiTCP:bin/route add default '||prefs.gateway
  1083.     'echo >T:tcpmounter "Assign TCP: Exists >NIL:"'
  1084.     'echo >>T:tcpmounter "if warn"'
  1085.     'echo >>T:tcpmounter "mount TCP: from AmiTCP:devs/inet-mountlist"'
  1086.     'echo >>T:tcpmounter "endif"'
  1087.     'execute T:tcpmounter >NIL:'
  1088.     'run AmiTCP:bin/inetd >NIL:'
  1089.     address
  1090.     'zSetAttr Status Value "Connected to 'prefs.hostname'!"'
  1091.     flags.tcponline = 1
  1092.     call GetHostName()
  1093.     return 0
  1094.  
  1095.  
  1096.